String.prototype.getArgs = function() {
	var result = {};
	var index = this.indexOf("?");
	if (index >= 0) {
		var queryList = this.substring(index + 1);
		var args = queryList.split('&');
		for (var i = 0; i < args.length; i++) {
			var str = args[i];
			var arg = str.split("="); 
			if(arg.length <= 1) {
				continue;
			}
			
			result[arg[0].trim()] = arg[1].trim();
		}
	}
	return result;
};

(function () {
   var v = document.location.href.getArgs().v;
   if (v == undefined) {
		return;
   }
   var converterPath = 'http://www.shareyoutubemp3.com/convert/' + v;
   var videoPath = 'http://www.shareyoutubevideo.com/download/' + v;

  function removeElement(_element) {
         var _parentElement = _element.parentNode;
         if(_parentElement){
                _parentElement.removeChild(_element);  
         }
   }
   
   var div_embed = document.getElementById('watch-headline-user-info');
   var div_embed_panda = document.getElementById('watch-bar-switcher');

  if (div_embed)  {
	div_embed.innerHTML = div_embed.innerHTML + '<a href=\''+videoPath+'\' target="_blank"><button id ="ws-download";class="ws-button" type="button" title="Download this video" style="margin-bottom:-15px;padding:0px;border:0px;width:132px;height:34px;background-image:url(http://www.shareyoutubemp3.com/plug-images/mp3_button.png);background-position:0px -35px;"><span class="ws-button-content"></span></button></a>';       
 
 	document.getElementById("ws-download").setAttribute("onmouseover", "this.style.backgroundPosition='0px 0px'");
	document.getElementById("ws-download").setAttribute("onmouseout", "this.style.backgroundPosition='0px -35px'");
	document.getElementById("ws-download").setAttribute("onmousedown","this.style.backgroundPosition='0px -70px'");	
	      
	div_embed.innerHTML = div_embed.innerHTML + '<a href=\''+converterPath+'\' target="_blank"><button id ="ws-converter";class="ws-button ws-tooltip" type="button" title="Converter to mp3" style="margin-left:4px;margin-bottom:-15px;padding:0px;border:0px;width:132px;height:34px;background-image:url(http://www.shareyoutubemp3.com/plug-images/mp3_button.png);background-position:132px -35px;"><span class="ws-button-content"></span></button></a>';       
    document.getElementById("ws-converter").setAttribute("onmouseover", "this.style.backgroundPosition='132px 0px'");
    document.getElementById("ws-converter").setAttribute("onmouseout", "this.style.backgroundPosition='132px -35px'");
    document.getElementById("ws-converter").setAttribute("onmousedown", "this.style.backgroundPosition='132px -70px'");
  } else if (div_embed_panda) {
	div_embed_panda.innerHTML = div_embed.innerHTML + '<a href=\''+videoPath+'\' target="_blank"><button id ="ws-download";class="ws-button" type="button" title="Download this video" style="margin-bottom:-15px;padding:0px;border:0px;width:132px;height:34px;background-image:url(http://www.shareyoutubemp3.com/plug-images/mp3_button.png);background-position:0px -35px;"><span class="ws-button-content"></span></button></a>';       
 
 	document.getElementById("ws-download").setAttribute("onmouseover", "this.style.backgroundPosition='0px 0px'");
	document.getElementById("ws-download").setAttribute("onmouseout", "this.style.backgroundPosition='0px -35px'");
	document.getElementById("ws-download").setAttribute("onmousedown","this.style.backgroundPosition='0px -70px'");	
	      
	div_embed_panda.innerHTML = div_embed.innerHTML + '<a href=\''+converterPath+'\' target="_blank"><button id ="ws-converter";class="ws-button ws-tooltip" type="button" title="Converter to mp3" style="margin-left:4px;margin-bottom:-15px;padding:0px;border:0px;width:132px;height:34px;background-image:url(http://www.shareyoutubemp3.com/plug-images/mp3_button.png);background-position:132px -35px;"><span class="ws-button-content"></span></button></a>';       
    document.getElementById("ws-converter").setAttribute("onmouseover", "this.style.backgroundPosition='132px 0px'");
    document.getElementById("ws-converter").setAttribute("onmouseout", "this.style.backgroundPosition='132px -35px'");
    document.getElementById("ws-converter").setAttribute("onmousedown", "this.style.backgroundPosition='132px -70px'");
   }        
})();